package com.nuvo.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;


@Entity
@Table(name = "MENU_TIPOUSUARIO")
@XmlRootElement
@NamedQueries({
    
    @NamedQuery(name = "MenuTipousuario.findByMenuAndTipousuario", query = "SELECT m FROM MenuTipousuario m WHERE m.menuId = :menu AND m.tipousuarioId = :tipo")
    })
public class MenuTipousuario implements Serializable {

    

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    
    @Column(name = "CREATED")
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;
    
    @Column(name = "UPDATED")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updated;

    @NotNull(message = "debe seleccionar un tipo de usuario")
    @JoinColumn(name = "TIPOUSUARIO_ID", referencedColumnName = "ID")
    @ManyToOne
    private Tipousuario tipousuarioId;

    @NotNull(message = "debe seleccionar un menu")
    @JoinColumn(name = "MENU_ID", referencedColumnName = "ID")
    @ManyToOne
    private Menu menuId;

  

    public MenuTipousuario() {
    }

    public MenuTipousuario(Integer id) {
        this.id = id;
    }

    

    public Integer getId() { return id; }
    public void setId(Integer id) { this.id = id; }

    public Date getCreated() { return created; }
    public void setCreated(Date created) { this.created = created; }

    public Date getUpdated() { return updated; }
    public void setUpdated(Date updated) { this.updated = updated; }

    public Tipousuario getTipousuarioId() { return tipousuarioId; }
    public void setTipousuarioId(Tipousuario tipousuarioId) { this.tipousuarioId = tipousuarioId; }

    public Menu getMenuId() { return menuId; }
    public void setMenuId(Menu menuId) { this.menuId = menuId; }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final MenuTipousuario other = (MenuTipousuario) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if (this.tipousuarioId != other.tipousuarioId && (this.tipousuarioId == null || !this.tipousuarioId.equals(other.tipousuarioId))) {
            return false;
        }
        if (this.menuId != other.menuId && (this.menuId == null || !this.menuId.equals(other.menuId))) {
            return false;
        }
        return true;
    }

    

   

    @Override
    public String toString() {
        return tipousuarioId.getNombre() + " - " + menuId.getNombre();
    }
    
}
